#include <limits.h>
#include "Matrix.h"
#include "gtest/gtest.h"

TEST(one, add) {

	int arr[rows][cols] = {{1,2},{2,1}};
	int arr2[rows][cols] = {{2,4},{4,2}};
	int **values = new int*[rows];
	for(int i=0; i<rows; i++)
	{
		values[i] = new int[cols];
		for(int j=0; j<cols; j++)
			values[i][j] = arr[i][j];
	}
	Matrix matA(values);
	Matrix matB(values);

	Matrix *matC = matA.add(matB);
	for(int i=0; i<rows; i++)
		for(int j=0; j<cols; j++)
			EXPECT_EQ(matC->arr[i][j], arr2[i][j]);
}

TEST(two, mul) {

	int arr[rows][cols] = {{1,2},{2,1}};
	int arr2[rows][cols] = {{5,4},{4,5}};
	int **values = new int*[rows];
	for(int i=0; i<rows; i++)
	{
		values[i] = new int[cols];
		for(int j=0; j<cols; j++)
			values[i][j] = arr[i][j];
	}
	Matrix matA(values);
	Matrix matB(values);

	Matrix *matC = matA.mul(matB);
	for(int i=0; i<rows; i++)
		for(int j=0; j<cols; j++)
			EXPECT_EQ(matC->arr[i][j], arr2[i][j]);
}

TEST(three, both) {

	int arr[rows][cols] = {{1,2},{2,1}};
	int arr2[rows][cols] = {{6,6},{6,6}};
	int **values = new int*[rows];
	for(int i=0; i<rows; i++)
	{
		values[i] = new int[cols];
		for(int j=0; j<cols; j++)
			values[i][j] = arr[i][j];
	}
	Matrix matA(values);
	Matrix matB(values);
	Matrix matD(values);

	Matrix *matC = matA.mul(matB);
	Matrix *matE = matC->add(matD);
	for(int i=0; i<rows; i++)
		for(int j=0; j<cols; j++)
			EXPECT_EQ(matE->arr[i][j], arr2[i][j]);
}